<template>
  <div>
    <!-- 标题操作栏 -->
    <div class="bannerOP">
      <span style="margin-left: 10px; color: #b30000; font-weight: 600;">
        <Icon name="apps" style="margin-top: 12px; margin-right: 5px;" />
        欢迎使用可信应用创新实验室管理系统
      </span>
      <Button type="link" style="float: right; height: 40px; margin-right: 10px; color: #b30000;" @click="showInOverview = !showInOverview">
        &lt;{{ showInOverview ? '概览模式' : '详细模式' }}&gt;
      </Button>
    </div>

    <!-- 主体内容区 -->
    <div style="margin-top: 5px;">
      <!-- 概览模式 -->
      <overview-part 
        :refData="{ ...sumData }" 
        v-show="showInOverview"/>

      <!-- 详细模式 -->
      <detail-part
        :refData="{
          ...sumData,
          resultTypes: dict.type.result,
          reviewTask: reviewTask,
          reviewTaskDoing: reviewTaskDoing,
          reviewTaskDone: reviewTaskDone,
          reviewTaskTotal: reviewTaskTotal
        }" 
        v-show="!showInOverview"/>
    </div>
  </div>
</template>

<script>
import { Message } from '@uni/vue';
import { getData } from "@/api/index/index";
import { listResult } from "@/api/doreview/reviewresult";
import overviewPart from "@/components/HomePage/OverviewPart.vue";
import detailPart from "@/components/HomePage/DetailPart.vue";

export default {
  name: "app",
  dicts: ['result'],
  components: {
    overviewPart, 
    detailPart
  },
  data: function () {
    return {
      showInOverview: true,
      sumData: {},
      reviewTask: [],
      reviewTaskDoing: [],
      reviewTaskDone: [],
      reviewTaskTotal: 0
    }
  },
  mounted: async function () {
    await this.queryData();
  },
  methods: {
    queryData: async function () {
      // 查询统计信息
      let rs = await getData();
      if (rs.code !== 200) return Message.error({ text: '查询首页预览信息失败：' + rs.msg });
      // console.log("getData rs: ", rs);
      this.sumData = rs.data;

      // 查询评测信息
      rs = await listResult();
      if (rs.code !== 200) return Message.error({ text: '获取评测结果列表信息失败：' + rs.msg });
      // console.log("listResult rs: ", rs);
      this.reviewTask = rs.rows.slice(0,7);
      this.reviewTaskDoing = this.reviewTask.filter(task => { return task.evaluationProgress !== '已完成' });
      this.reviewTaskDone = this.reviewTask.filter(task => { return task.evaluationProgress == '已完成' });
      this.reviewTaskTotal = rs.total;
    }
  }
}
</script>

<style scoped>
  /* 标题栏操作区 */
  .bannerOP {
    background-color: #E9EBF0;
    height: 40px;
    line-height: 40px;
    border-radius: 3px;
  }

  /* 跑马灯滚动区 */
  .carousel-area {
    margin-top: 5px;
  }
</style>
